﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WeakScript
{
    public class Registr
    {
        public static List<String> FunctionsNames { get; set; }
        public static List<String> TypesNames { get; set; }
        public static List<String> ConstsNames { get; set; }
        public static List<String> VarNames { get; set; }

        public static Dictionary<string, long> TypesMap;
        
        static Registr()
        {
            Clean();
        }

        public static void Clean(){
            FunctionsNames = new List<string>();
            TypesNames = new List<string>();
            ConstsNames = new List<string>();
            VarNames = new List<string>();
            TypesMap = new Dictionary<string, long>();

            FunctionsNames.AddRange(new string[]{"Sin","Cos","Abs"});

            //TypesMap["bool"] = (long)WeakVar.InternalType.BOOL;
            //TypesMap["float"] = (long)WeakVar.InternalType.FLT;
            //TypesMap["char"] = (long)WeakVar.InternalType.CHR;
            //TypesMap["string"] = (long)WeakVar.InternalType.STR;
            //TypesMap["ref"] = (long)WeakVar.InternalType.REF;

            TypesMap["bool"] = (long)Global.GetUK();
            TypesMap["float"] = (long)Global.GetUK();
            TypesMap["char"] = (long)Global.GetUK();
            TypesMap["string"] = (long)Global.GetUK();
            TypesMap["ref"] = (long)Global.GetUK();

            Registr.TypesNames.AddRange(TypesMap.Keys.ToArray());
        }

        public static bool IsInner(string typename)
        {
            return
                (typename == "bool" ||
                typename == "float" ||
                typename == "char" ||
                typename == "string");
        }

        public static WeakVar.InternalType GetInnerType(string typename)
        {

            if (typename == "bool")     return WeakVar.InternalType.BOOL;
            if (typename == "float")    return WeakVar.InternalType.FLT;
            if (typename == "char")     return WeakVar.InternalType.CHR;
            if (typename == "string")   return WeakVar.InternalType.STR;

            return WeakVar.InternalType.REF;
        }
        
    }
}
